<?php
/**
 * 核心Db框架
 * @author sunhaoqiang(shqdev@163.com)
 * @time: 2019-08-25 16:38
*/
namespace app\item;

use script\Db;
use script\Item;

class Study extends Item
{
    protected $table = 't_question';
    protected $item = [
        "question_id" => '',
        "question_type" => '',
        "question_channel_type" => '',
        "channel_type_name" => '',
        "title" => '',
        "question_text" => '',
        "options" => '',
        "answer_json" => '',
        "answer" => '',
        "explanation" => '',
        "knowledge" => '',
        "t_knowledge" => '',
        "category" => '',
        "parent_id" => '',
        "paperid" => '',
        "xd" => '',
        "chid" => '',
        "exam_type" => '',
        "exam_name" => '',
        "difficult_index" => '',
        "difficult_name" => '',
        "is_objective" => '',
        "is_collect" => '',
        "extra_file" => '',
        "save_num" => '',
        "new_flag" => '',
        "is_use" => '',
        "question_source" => '',
        "score" => '',
        "subScore" => '',
        "list" => '',
        "add_time" => '',
        "grade_id" => '',
        "sub_id" => '',
        "chapter_id" => ''
    ];

    public function questionSingle($question)
    {
        $question = (array)$question;

        if (empty($question)) {
            return [];
        }
        
        $data = [
            "question_id" => $question["question_id"],
            "question_type" => $question["question_type"],
            "question_channel_type" => $question["question_channel_type"],
            "channel_type_name" => $question["channel_type_name"],
            "title" => $question["title"],
            "question_text" => $question["question_text"],
            "options" => ($question["options"]),
            "answer_json" => $question["answer_json"],
            "answer" => $question["answer"],
            "explanation" => $question["explanation"],
            "knowledge" => $question["knowledge"],
            "t_knowledge" => $question["t_knowledge"],
            "category" => $question["category"],
            "parent_id" => $question["parent_id"],
            "paperid" => $question["paperid"],
            "xd" => $question["xd"],
            "chid" => $question["chid"],
            "exam_type" => $question["exam_type"],
            "exam_name" => $question["exam_name"],
            "difficult_index" => $question["difficult_index"],
            "difficult_name" => $question["difficult_name"],
            "is_objective" => $question["is_objective"],
            "is_collect" => $question["is_collect"],
            "extra_file" => $question["extra_file"],
            "save_num" => $question["save_num"],
            "new_flag" => $question["new_flag"],
            "is_use" => $question["is_use"],
            "question_source" => $question["question_source"],
            "score" => isset($question["score"])? $question["score"] :'',
            "subScore" => isset($question["subScore"])? $question["subScore"] :'',
            "list" => isset($question["list"])? $question["list"] :'',
            "add_time" => date('Y-m-d H:i:s'),
            "grade_id" => isset($question["grade_id"])? $question["grade_id"] :'',
            "sub_id" => isset($question["sub_id"])? $question["sub_id"] :'',
            "chapter_id" => isset($question["chapter_id"])? $question["chapter_id"] :''
        ];
        $this->push($data);
        return $data;
        
    }
}